<?php

namespace Modules\Admin\app\Http\Requests;

use App\Base\ApiRequest;

class LoginRequest extends ApiRequest
{
    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        $rule = [
            'username' => ['required'],
            'password' => ['required'],
            
        ];

        if (config('admin.captcha_enabled')) {
            $rule['code'] = ['required'];
            $rule['secret_str'] = ['required'];
        }
        return $rule;
    }

    /**
     * Undocumented function
     *
     * @return 
     */
    public function messages()
    {
        $message = [
            'username.required' => '请输入用户名',
            'password.required' => '请输入密码',
            
        ];

        if (config('admin.captcha_enabled')) {
            $message['code.required'] = '请输入验证码';
            $message['secret_str.required'] = '请输入验证码';
        }
        return $message;
    }

    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }
}
